﻿﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>合同管理</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.5.8/css/sm.min.css">
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.5.8/css/sm-extend.min.css">
    <link href="//cdn.bootcss.com/font-awesome/4.5.0/css/font-awesome.css" rel="stylesheet" />
    <link href="/View_Mobile/CSS/szhlextend.css?ver=20160904" rel="stylesheet" />
    <!--<link rel="stylesheet" href="/View_Mobile/CSS/animate.css">-->
    <style type="text/css">
        .ms-controller, [ms-controller] {
            display: none;
        }

        #plus_list {
            height: 2.65rem;
            width: 2.65rem;
            position: fixed;
            right: 0.82rem;
            bottom: 6rem;
        }

            #plus_list img {
                width: 100%;
                height: auto;
            }
    </style>
</head>
<body ms-controller="UI_HTGL_LIST">
    <div class="page-group">
        <div class="page page-current" id="pageindex1">
            <div class="buttons-tab">
                <a href="#" ms-if="DataID=='-1'" ms-on-click="getdata(1)" class="tab-link button external" ms-class-1="active:type=='1'">我创建的</a>
                <a href="#" ms-if="DataID=='-1'" ms-on-click="getdata(2)" class="tab-link button external" ms-class-1="active:type=='2'">下属合同</a>
            </div>
            <div class="content infinite-scroll infinite-scroll-bottom" data-distance="50" style="margin-top:2rem" id="touchcontent">
                <div class="list-container">
                    <div class="card facebook-card animated fadeInUp" ms-repeat-el="ctData">
                        <div class="ribbon-wrapper-green"><div class="ribbon-green">{{el.TypeName}}</div></div>
                        <!--<div class="card-header no-border" ms-on-click="showdetil(el)">
                            <div class="facebook-avatar"><img ms-src="/ViewV5/Base/DownFile.aspx?type=TX&user={{el.CRUser}}" style="border-radius: 3px;width:32px;height:32px"><div class="cadename" ms-if="!el.isfold">{{ComFunJS.convuser(el.CRUser)}}</div></div>
                            <div class="facebook-date" ms-if="el.isfold">{{ComFunJS.convuser(el.CRUser)}}</div>
                            <div class="facebook-date">{{$.timeago(el.CRDate)}}</div>
                            <div class="facebook-date">{{el.CRDate|date("MM月dd日")}}</div>
                            <div class="facebook-date" ms-if="!el.isfold" style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{covtitle(el.Title)}}</div>
                            <div class="facebook-date" ms-if="!el.isfold" style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{el.HTStatus}}</div>
                        </div>-->
                        <div class="card-header no-border" ms-on-click="showdetil(el)">
                            <div class="facebook-avatar">
                                <img ms-src="/ViewV5/Base/DownFile.aspx?type=TX&user={{el.CRUser}}" width="40" class="border-r">
                            </div>
                            <div class="facebook-date head-ft16">{{ComFunJS.convuser(el.CRUser)}}<span class="ml10 c999 ft14" ms-if="!el.isfold">{{$.timeago(el.CRDate)}}</span></div>
                            <div class="facebook-date head-ft16" ms-if="el.isfold"><span class="c999 ft14">{{el.CRDate|date("MM月dd日")}}</span></div>
                            <div class="facebook-date" ms-if="!el.isfold">
                                <span class="c999 title-item">合同标题：</span>
                                <span>{{covtitle(el.Title)}}</span>
                            </div>
                            <div class="facebook-date" ms-if="!el.isfold">
                                <span class="c999 title-item">合同状态：</span>
                                <span>{{el.HTStatus}}</span>
                            </div>
                            <div style="clear:both"></div>
                        </div>
                        <div class="card-content  " ms-visible="el.isfold">
                            <div class="card-item"><span class="c999 title-item">合同标题：</span> <span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{el.Title}}</span></div>
                            <div class="card-item"><span class="c999 title-item">对应客户：</span> {{el.KHName}}</div>
                            <div class="card-item" ms-if="el.FZR"><span class="c999 title-item">负责人：</span>{{ComFunJS.convuser(el.FZR)}}</div>
                            <div class="card-item" ms-if="el.Price"><span class="c999 title-item">合同总金额(元)：</span>{{el.Price}}</div>
                            <div class="card-item" ms-if="el.DanWei"><span class="c999 title-item">合同开始时间：</span>{{el.HTStartTime|date('yyyy-MM-dd')}}</div>
                            <div class="card-item" ms-if="el.ChengBen"><span class="c999 title-item">合同结束时间：</span>{{el.HTEndTime|date('yyyy-MM-dd')}}</div>
                            <div class="card-item" ms-if="el.TypeName"><span class="c999 title-item">合同状态：</span><span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{el.HTStatus}}</span></div>
                            <div class="card-item" ms-if="el.HTCode"><span class="c999 title-item">合同编号：</span> <span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{el.HTCode}}</span></div>
                            <div class="card-item" ms-if="el.CPName"><span class="c999 title-item">关联产品：</span> <span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{el.CPName}}</span></div>
                            <div class="card-item" ms-if="el.TypeName"><span class="c999 title-item">合同类型：</span> <span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{el.TypeName}}</span></div>
                            <div class="card-item" ms-if="el.FSName"><span class="c999 title-item">付款方式：</span> <span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{el.FSName}}</span></div>
                            <div class="card-item" ms-if="el.FKSM"><span class="c999 title-item">付款说明：</span> <span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{el.FKSM}}</span></div>
                            <div class="card-item" ms-if="el.KHQYR"><span class="c999 title-item">客户方签约人：</span> <span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{el.KHQYR}}</span></div>
                            <div class="card-item" ms-if="el.WFQYR"><span class="c999 title-item">我方签约人：</span> <span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{el.WFQYR}}</span></div>
                            <div class="card-item" ms-if="el.ExpiryDate"><span class="c999 title-item">有效期：</span> <span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{el.ExpiryDate}}</span></div>
                            <div class="card-item" ms-if="el.QYDate"><span class="c999 title-item">签约日期：</span> <span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{el.QYDate|date('yyyy-MM-dd')}}</span></div>
                            <div class="card-item" ms-if="el.Remark"><span class="c999 title-item">备注：</span> <span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{el.Remark|html}}</span></div>
                            <div class="card-item" ms-repeat-ext="el.SubExt"><span class="c999 title-item">{{ext.TableFiledName}}：</span> <span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{ext.ExtendDataValue}}</span></div>
                            <div class="card-item" ms-if="el.Files">
                                <ul class="filelist">
                                    <li ms-repeat-file="el.FileList">
                                        <img ms-class="mall_pcp:ComFunJS.isPic(file.FileExtendName)" class="" ms-on-click="viewfile(file)" ms-src="/ViewV5/Base/DownFile.aspx?fileId={{file.ID}}" />
                                        <span class="fileinfo" ms-if="!ComFunJS.isPic(file.FileExtendName)">{{file.Name}}</span>
                                    </li>
                                </ul>
                            </div>

                            <!--<div class="buttons-tab">
                                <a href="#" ms-on-click="getpldata(el,1)" class="tab-link button external" ms-class-1="active:el.pltype=='1'">跟进记录</a>
                                <a href="#" class="tab-link button external"></a>
                                <a href="#" class="tab-link button external"></a>
                                <a href="#" class="tab-link button external"></a>
                            </div>

                            <div class="list-container">
                                <div class="card facebook-card animated fadeInUp" ms-repeat-itemgjjl="el.GJJL" ms-visible="el.pltype=='1'">
                                    <div class="card-header no-border">
                                        <div class="facebook-avatar"><img ms-src="/ViewV5/Base/DownFile.aspx?type=TX&user={{itemgjjl.CRUser}}" style="border-radius: 3px;width:32px;height:32px"></div>
                                        <div class="facebook-date">{{ComFunJS.convuser(itemgjjl.CRUser)}}</div>
                                        <div class="facebook-date">{{$.timeago(itemgjjl.CRDate)}}</div>
                                    </div>
                                    <div class="card-content  ">
                                        <div class="card-content-inner" style="padding-bottom:0;    padding-top: 0.4rem;" ms-if="itemgjjl.Details"><span style="color:gray">描述：</span> <span style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{itemgjjl.Details|html}}</span></div>
                                        <div class="card-content-inner" style="padding-bottom:0;    padding-top: 0.4rem;" ms-if="itemgjjl.Type"><span style="color:gray">方式：</span> {{itemgjjl.Type}}</div>
                                        <div class="card-content-inner" style="padding-top: 0; padding-top: 0.4rem; padding-bottom: 0;" ms-if="itemgjjl.Files">
                                            <ul class="filelist">
                                                <li ms-repeat-file="itemgjjl.FileList">
                                                    <img ms-class="mall_pcp:ComFunJS.isPic(file.FileExtendName)" class="" ms-on-click="viewfile(file)" ms-src="/ViewV5/Base/DownFile.aspx?fileId={{file.ID}}" />
                                                    <span class="fileinfo" ms-if="!ComFunJS.isPic(file.FileExtendName)">{{file.Name}}</span>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                                <div ms-if="el.GJJL.size()==0" class="card-content-inner" style="padding-bottom:0;padding-top: 0.4rem;" ms-if="el.TypeName"><span style="color:gray">暂无数据</span> </div>
                            </div>-->

                            <div ms-visible="el.GJJL.size()>0">
                                <div class="lookright-box">
                                    <div class="menu-general">
                                        <ul>
                                            <li class="active">
                                                <a>跟进</a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                                <div id="map">
                                    <!--跟进-->
                                    <div style="display: block;">
                                        <!--评论样式-->
                                        <div class="crm-dt" ms-repeat-pl="el.GJJL">
                                            <span class="crm-yuan"></span>
                                            <div class="crm-dt-cont">

                                                <div class="m5">
                                                    <p class="c999">{{ComFunJS.convuser(pl.CRUser)}} <span class=" ft14 pull-right">{{pl.CRDate|date("MM月dd日")}}</span></p>
                                                    <h3 class="crm-xg ft14 mt5" style="word-break:break-all;word-wrap:break-word;">
                                                        {{ComFunJS.bqhContent(pl.Details)|html}}
                                                    </h3>
                                                    <ul class="filelist">
                                                        <li ms-repeat-file="pl.FileList">
                                                            <img ms-class="mall_pcp:ComFunJS.isPic(file.FileExtendName)" class="" ms-on-click="viewfile(file)" ms-src="/ViewV5/Base/DownFile.aspx?fileId={{file.ID}}" />
                                                            <span class="fileinfo" ms-if="!ComFunJS.isPic(file.FileExtendName)">{{file.Name}}</span>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="buttons-tab list-op">
                                <a class="tab-link button external" ms-click="addGJ(el)">
                                    <i class="iconfont icon-xiaoxi"></i>跟进
                                </a>
                                <a class="tab-link button external" ms-click="editHTGL(el)" ms-if="nowuser==el.CRUser">
                                    <i class="iconfont icon-bianji2"></i>编辑
                                </a>
                                <a class="tab-link button external" ms-click="delHTGL(el)" ms-if="nowuser==el.CRUser">
                                    <i class="iconfont icon-remove"></i>删除
                                </a>
                            </div>
                            
                        </div>
                        <!--<div class="card-footer no-border" style="display:-webkit-box;padding:0">
                            <a href="#" ms-click="addGJ(el)">&nbsp;跟进&nbsp;</a>
                            <a href="#" ms-click="editHTGL(el)" ms-if="nowuser==el.CRUser"><i class="fa fa-edit"></i>&nbsp;编辑&nbsp;</a>
                            <a href="#" ms-click="delHTGL(el)" ms-if="nowuser==el.CRUser"><i class="fa fa-gear"></i>&nbsp;删除&nbsp;</a>
                        </div>-->
                    </div>
                    <div class="card facebook-card animated" ms-if="loadtip">
                        <div class="card-header no-border">
                            {{loadtip}}
                        </div>
                    </div>
                </div>
                <div class="infinite-scroll-preloader">
                    <div class="preloader"></div>
                </div>
            </div>
            <!--<span class="animated fadeIn" ms-if="DataID=='-1'" ms-click="addHTGL()" id="plus_btn" style="z-index:99998;opacity:.9"><img src="/View_Mobile/images/plus_icon.png"></span>
            <span class="animated fadeIn" ms-if="DataID=='-1'" ms-click="changefold()" id="plus_list" style="z-index:99998;opacity:.9"><img ms-attr-src="'/View_Mobile/images/'+(isfold?'rwglss':'rwglzk')+'.png'"></span>-->
            <div class="right-panel">
                <ul>
                    <li>

                        <!--<a class="mod-li-icon" ms-if="DataID!='-1'" ms-click="viewall()"><img src="/View_Mobile/images/plus-zhankai.png"></a>-->
                        <a class="mod-li-icon" ms-if="DataID=='-1'" ms-click="changefold()"><img ms-attr-src="'/View_Mobile/images/'+(isfold?'plus-zhedie':'plus-zhankai')+'.png'" src="/View_Mobile/images/plus-zhedie.png"></a>


                    </li>
                    <li>

                        <a class="mod-li-icon" ms-if="DataID=='-1'" ms-click="addHTGL()"><img src="/View_Mobile/images/plus-add.png"></a>
                    </li>

                </ul>

            </div>
        </div>
        <div class="page" id="pageindex2">
        </div>
    </div>
    <script src="/View_Mobile/JS/layer/layer.m.js"></script>
    <script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.5.8/js/sm.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.5.8/js/sm-extend.min.js' charset='utf-8'></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
    <script src="/View_Mobile/JS/touch/toucher.js"></script>
    <script src="/View_Mobile/JS/avalon.mobile.min.js"></script>
    <script src="/View_Mobile/JS/raty/jquery.raty.js?v=1.3"></script>
    <script src="/View_Mobile/JS/ComFunJS.js?jsver=20160425"></script>
    <script>
      
        var model = avalon.define({
            $id: "UI_HTGL_LIST",
            ctData: [],//数据源
            loading: false,
            type: 1,
            loadtip: "",//切换页时显示信息
            nowuser: ComFunJS.getnowuser(),//当前用户
            isfold: localStorage.getItem("HTGLisfold") == "Y" ? true : false,//是否折叠显示
            changefold: function () {
                model.isfold = !model.isfold;
                model.ctData.forEach(function (item) {
                    item.isfold = model.isfold;
                })
                localStorage.setItem("HTGLisfold", model.isfold ? "Y" : "N");
            },//改变折叠状态
            page: 1,
            pagecount: 8,
            DataID: ComFunJS.getQueryString("ID", "-1"),//数据ID
            covtitle: function (title) {
                return ComFunJS.convstr($("<div>" + title + "</div>").text(), 20);
            },//转化 TITLE信息
            showdetil: function (item) {
                item.isfold = !item.isfold
            },//展开显示信息
            addHTGL: function (el) {
                window.location = "/View_Mobile/UI/BASE/APP_MOBIL_WF.html?FormCode=HTGL&r=" + Math.random();
            },
            editHTGL: function (el) {
                //路由加载
                window.location = "/View_Mobile/UI/BASE/APP_MOBIL_WF.html?FormCode=HTGL&id=" + el.ID + "&r=" + Math.random();
            },
            addGJ: function (el) {
                window.location = "/View_Mobile/UI/BASE/APP_MOBIL_WF.html?FormCode=HTGJ&htid=" + el.ID + "&r=" + Math.random();
            },
            delHTGL: function (el) {
                if (event.stopPropagation) {
                    event.stopPropagation();
                }
                $.confirm("确认要删除吗", function () {
                    $.post('/API/VIEWAPI.ashx?Action=CRM_DELHTBYID', { "P1": el.ID }, function (result) {
                        result = JSON.parse(result)
                        if (result.ErrorMsg == "") {
                            ComFunJS.winsuccess("删除成功");
                            model.ctData.remove(el);
                            if (model.ctData.size() == 0) {
                                model.loadtip = '没有找到数据哦'
                            }
                        }
                    })
                }
               )

            },
            loadMore: function () {
                if (model.loading) return;
                model.loading = true;
                $.getJSON("/API/VIEWAPI.ashx?Action=CRM_GETHTLIST&r=" + Math.random(), { "p": model.page, ID: model.DataID, P1: model.type }, function (r) {
                    model.loading = false;
                    if (r.ErrorMsg == "") {
                        if (model.page == 1 && r.Result.length == 0) {
                            model.loadtip = '没有找到数据哦'
                        }
                        for (var i = 0; i < r.Result.length; i++) {
                            r.Result[i].isfold = model.isfold;
                            if (model.DataID != "-1") {//如果有数据ID，则展开显示
                                r.Result[i].isfold = true;
                            }
                            r.Result[i].pltype = "1";
                        }

                        model.ctData.pushArray(r.Result);
                        //判断是否加载完毕
                        if (r.Result.length < model.pagecount) {
                            // 加载完毕，则注销无限加载事件，以防不必要的加载
                            $.detachInfiniteScroll($('.infinite-scroll'));
                            // 删除加载提示符
                            $('.infinite-scroll-preloader').hide();
                            return;
                        }
                        $.refreshScroller();
                        model.page += 1;
                    }

                });

            },
            viewfile: function (file) {
                if (ComFunJS.isPic(file.FileExtendName)) {
                    ComFunJS.viewbigimg(this)
                    return;
                }
                if (ComFunJS.isOffice(file.FileExtendName) && file.ISYL == "Y") {
                    window.location = file.YLUrl;
                    return;
                }
            },//
            getdata: function (type) {
                $.attachInfiniteScroll($('.infinite-scroll'))
                model.loadtip = "";
                $('.infinite-scroll-preloader').show();
                model.ctData.clear();
                model.page = 1;
                model.type = type;
                model.loadMore();
            }, showHTStatus: function (status) {
                var statusName = "";
                switch (status) {
                    case "0":
                        statusName = "未开始";
                        break;
                    case "1":
                        statusName = "执行中";
                        break;
                    case "2":
                        statusName = "成功结束";
                        break;
                    case "3":
                        statusName = "意外终止";
                        break;
                }
                return statusName;
            }
        })
        avalon.ready(function () {
            // 注册'infinite'事件处理函数
            $(document).on('infinite', '.infinite-scroll-bottom', function () {
                model.loadMore();
            });

            $.init();
            model.getdata(model.type);
        })
    </script>
</body>
</html>